<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>图片二维码识别</title>
    </head>
    <body>

        <div>
          <video></video>
        </div>
    </body>
    <script type="text/javascript">
      video()
      function video() {
        var constraints = { audio: true, video: true };
        navigator.mediaDevices.getUserMedia(constraints)
          .then(function(stream) {
            /* 使用这个 stream stream */
            var video = document.querySelector('video');
            video.srcObject = mediaStream;
            video.onloadedmetadata = function(e) {
              video.play();
            };
          })
          .catch((err) => {
            /* 处理 error */
             console.log(err.name + ": " + err.message);
          });
      }
    </script>
</html>
